package com.xujl.datalibrary.task;

import android.util.Log;

import com.xujl.datalibrary.bean.RequestBean;
import com.xujl.datalibrary.bean.RequestLoginBean;
import com.xujl.datalibrary.bean.ResponseBean;
import com.xujl.datalibrary.util.JsonParseUtils;

/**
 * <pre>
 *     @author : xujl
 *     e-mail : 597355068@qq.com
 *     time   : 2018/11/14
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class TaskNetwork implements TaskInterface {
    private static final String TAG = "TaskNetwork";

    @Override
    public void runTask (final RequestBean taskBean, final TaskCallback callback) {
        final RequestLoginBean loginBean = JsonParseUtils.fromJson(taskBean.getParamsJson(), RequestLoginBean.class);
        Log.d(TAG, taskBean.getParamsJson());
        new Thread(new Runnable() {
            @Override
            public void run () {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                final ResponseBean responseBean = new ResponseBean();
                responseBean.setCode(100);
                responseBean.setMessage("登录成功！");
                responseBean.setRequestCode(taskBean.getRequestCode());
                callback.onTaskComplete(JsonParseUtils.toJson(responseBean));
            }
        }).start();
    }
}
